from fastapi import APIRouter, Depends
from sqlalchemy.orm import Session
from database import get_db

router = APIRouter()

@router.get("/health")
async def health_check():
    return {"status": "ok", "message": "应用程序运行正常"}

@router.get("/db-check")
async def db_check(db: Session = Depends(get_db)):
    try:
        result = db.execute("SELECT 1")
        return {"status": "ok", "message": "数据库连接正常", "result": result.scalar()}
    except Exception as e:
        return {"status": "error", "message": str(e)}